import javax.swing.JOptionPane;

public class Attack extends ActionOrder{

	public Attack(Player Owner, Territory Source, Territory Destination, int[] TroopAmount){
        super(Owner, Source, Destination, TroopAmount); 
    }
	
	protected boolean checkOwner(){
		if(Source.getOwner() != Owner){
			JOptionPane.showMessageDialog(null, "You can only use your own territory!");
			 return false;
		}
		if (Source.getOwner() != Destination.getOwner()) return true;
        else {
        	JOptionPane.showMessageDialog(null, "You can only attack an enemy's territory!");
            return false;
        }
    }

    protected boolean checkPath(Map m){
        if (Source.CheckNeighbor(Destination)) return true;
        else {
        	JOptionPane.showMessageDialog(null, "You can only attack a adjacent territory!");
            return false;
        }
    }
    
    public  String printOrder(){
    	StringBuffer sentence = new StringBuffer();
    	sentence.append("Attack");
    	sentence.append(Destination.getLocation() + "by ");
    	for (int i = 0; i < 6; i++)
    		if (TroopAmount[i] > 0){
    		sentence.append(String.valueOf(TroopAmount[i]));
    		sentence.append(" " + TechnologyName[i] + ", ");
    	}
    	sentence.append(" from " + Source.getLocation());
        return sentence.toString();
    }
}
